package com.bainarm.library_fragment;

import android.os.Bundle;

import androidx.fragment.app.Fragment;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.Toast;

/**
 * A simple {@link Fragment} subclass.
 * Use the {@link OkNgButtonsFragment#newInstance} factory method to
 * create an instance of this fragment.
 */
public class OkNgButtonsFragment extends Fragment {

    // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
    private static final String ARG_PARAM1 = "now_step";
    private static final String ARG_PARAM2 = "next_step";


    private String mNowStep;
    private String mNextStep;

    public OkNgButtonsFragment() {
        // Required empty public constructor
    }

    /**
     * Use this factory method to create a new instance of
     * this fragment using the provided parameters.
     *
     * @param param1 Parameter 1.
     * @param param2 Parameter 2.
     * @return A new instance of fragment OkNgBunttonFragment.
     */

    public static OkNgButtonsFragment newInstance(String param1, String param2) {
        OkNgButtonsFragment fragment = new OkNgButtonsFragment();
        Bundle args = new Bundle();
        args.putString(ARG_PARAM1, param1);
        args.putString(ARG_PARAM2, param2);
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (getArguments() != null) {
            mNowStep = getArguments().getString(ARG_PARAM1);
            mNextStep = getArguments().getString(ARG_PARAM2);
        }
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View rootView = inflater.inflate(R.layout.fragment_ok_ng_buntton, container, false);

        Button okButton = rootView.findViewById(R.id.okButton);
        Button ngButton = rootView.findViewById(R.id.ngButton);

        okButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                // 处理 "OK" 按钮点击事件的逻辑
                Toast.makeText(getContext(), "mNowStep："+mNowStep, Toast.LENGTH_SHORT).show();

            }
        });

        ngButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                // 处理 "NG" 按钮点击事件的逻辑
                Toast.makeText(getContext(), "mNextStep：" + mNextStep, Toast.LENGTH_SHORT).show();

            }
        });

        return rootView;
    }

}